import numpy as np
from scipy.stats import rankdata

# 示例多个指标数据
data = {
    'variance_cpu': np.array([0.2, 0.3, 0.4, 0.3, 0.2]),
    'variance_memory': np.array([100, 200, 150, 200, 100]),
    'average_cpu': np.array([50, 55, 60, 55, 50]),
    'average_memory': np.array([1000, 1100, 1050, 1100, 1000])
}

# 对每个指标计算排名
ranked_data = {}
for key, values in data.items():
    ranked_data[key] = rankdata(-values, method='dense')

# 输出排名结果
for key, ranks in ranked_data.items():
    print(f"{key}: {ranks}")
print()
